﻿using Lhz.InternetService;
using Lhz.Pp.Business;
using Lhz.Pp.Entity.Database;
using Lhz.Test.Common;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace Lhz.Pp.Test.LhzPpService
{
    [TestClass]
    public class UnitTestUser
    {
        [TestMethod]
        public void UserServiceTestMethodCommon()
        {
            var item = EntityFactory.BuildUser();
            var sct = new ServiceCrudTester<Guid, User>(TestConst.UrlServiceUser);
            var changes = new Dictionary<string, object>();
            changes.Add("Username", "Username");
            changes.Add("Password", "Password");
            changes.Add("Name", "Name");
            changes.Add("Phone", "Phone");
            sct.CrudTest(item, item.Guid, changes);
        }

        [TestMethod]
        public void UserServiceTestMethodQueryByUsernameAndPassword()
        {
            var user = EntityFactory.BuildUser();
            var up = new UserProxy();
            up.Add(user);
            var si = new ServiceInvoker(typeof(User));
            var queryUser = si.Invoke<User>(TestConst.UrlServiceUser, "QueryByUsernameAndPassword", user.Username, user.Password);
            Assert.IsNotNull(queryUser);
        }
    }
}
